<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>div+css+js实现弹出框</title>
    <script src="js/jquery-3.3.1.js"></script>
    <style>
        /*背景层*/
        #popLayer {
            display: none;
            background-color: #B3B3B3;
            position: absolute;
            /*float:left;*/
            border:1px solid blue;
            top: 0px;
            right: 0px;
           width:100%;
            height:100%;
            z-index: 10;
            -moz-opacity: 0.8;
            opacity:.80;
            filter: alpha(opacity=80);/* 只支持IE6、7、8、9 */
        }

        /*弹出层*/
        #popBox {
            display: none;
            background-color: #FFFFFF;
            z-index: 11;
            width: 200px;
            height: 200px;
            position:absolute;
            top:0;
            right:0;
            left:0;
            bottom:0;
            margin:auto;
        }

        #popBox .close{
            text-align: right;
            margin-right: 5px;
            background-color: #F8F8F8;
        }

        /*关闭按钮*/
        #popBox .close a {
            text-decoration: none;
            color: #2D2C3B;
        }

    </style>
</head>
<body>
<input type="button" name="popBox" value="弹出框" onclick="popBox()">

<div style="position:relative;width:800px;height:500px;border: 1px solid red;">5555555555555
    <div id="popLayer"></div>
    <div id="popBox">
        <div class="close">
            <a href="javascript:void(0)" onclick="closeBox()">关闭</a>
        </div>
        <div class="content">我是弹出层</div>
    </div>

</div>


<script>
    /*点击弹出按钮*/
    function popBox() {
        var popBox = document.getElementById("popBox");
        var popLayer = document.getElementById("popLayer");
        popBox.style.display = "block";
        popLayer.style.display = "block";
    };

    /*点击关闭按钮*/
    function closeBox() {
        var popBox = document.getElementById("popBox");
        var popLayer = document.getElementById("popLayer");
        popBox.style.display = "none";
        popLayer.style.display = "none";
    }
</script>
</body>
</html>
